package com.qf.java2102.qihaonan.hotel.entity;

import java.util.List;

/**
 * 分页实体
 * @author aa
 * @version 1.0
 */
public class PageBean<T> {

    /**
     * 当前页
     */
    private Integer currentPage;

    /**
     * 页大小
     */
    private Integer pageSize = 6;

    /**
     * 总条数
     */
    private Long totalCounts;

    /**
     * 总页数
     *  计算得到：总条数%页大小 == 0 ? 总条数/页大小 + 总条数/页大小+1
     */
    private Integer totalPages;

    /**
     * 当前页集合
     */
    private List<T> list;

    public PageBean() {
    }

    public PageBean(Integer currentPage, Integer pageSize, Long totalCounts, Integer totalPages, List<T> list) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCounts = totalCounts;
        this.totalPages = totalPages;
        this.list = list;
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Long getTotalCounts() {
        return totalCounts;
    }

    public void setTotalCounts(Long totalCounts) {
        this.totalCounts = totalCounts;
    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages() {
        int count = totalCounts.intValue();
        this.totalPages = count % pageSize == 0 ? (count / pageSize) : (count / pageSize + 1);
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
